from rest_framework import serializers
from .models import *
from rest_framework.exceptions import ValidationError

# 部门的序列化器
class DepartmentSerializer(serializers.Serializer):
    id = serializers.IntegerField(label='ID',read_only=True)
    name = serializers.CharField(label='部门名称',min_length=2,max_length=10,
                                 allow_null=True,allow_blank=True,trim_whitespace=True)
    def valiphone(self,att):
        depart = att.get('depart')
    def create(self,validated_data):
        depart = Department.objects.create(**validated_data)
        return depart
# 职位的序列化器
class DutySerializer(serializers.Serializer):
    id = serializers.IntegerField(label='ID',read_only=True)
    name = serializers.CharField(label='职位名称',min_length=2,max_length=10,
                                 allow_null=True,allow_blank=True,trim_whitespace=True)
    def valiphone(self,att):
        dut = att.get('dut')
    def create(self,validated_data):
        dut = Department.objects.create(**validated_data)
        return dut

# 职位的序列化器
class StaffSerializer(serializers.ModelSerializer):
    class Meta:
        model =Staff
        fields = '__all__'


